<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>特码返水管理</title>
<%@include file="/WEB-INF/base.jspf"%>
<style>
#test1 {
	margin: 2px;
	height: 37px;
}
	.modal-dialog {
		max-width: 1000px;
	}
#test2 {
	margin: 2px;
	height: 37px;
}

#qblx {
	margin: 2px;
	height: 37px;
}

#zflx {
	margin: 2px;
	height: 37px;
}

.layui-inline {
	height: 100px;
}

#hymc {
	margin: 2px;
	height: 37px;
}

.layui-inline-dd {
	margin-top: 40px;
}

#hymc-qihao {
	height: 37px;
	margin-top: 2px;
}

.dataTables_length {
	margin-top: 12px;
	margin-left: 50px;
}

.tableSearch {
	position: relative;
}

.class-span-searchBtn {
	height: 24px;
	width: 36px;
	font-size: 14px;
	text-algin: center;
	line-height: 25px;
	padding: 0 !important;
	position: absolute;
	right: 20px;
	top: 12px;
}

.class-input-pageNumber {
	width: 40px;
	height: 23px;
	position: absolute;
	right: 58px;
	top: 12px;
}

#table_id_example_paginate {
	margin-right: 100px;
}

.class-th {
	width: 320px;
	text-align: center;
}
.nav-fake {
padding-left: 0;
    margin-bottom: 0;
    list-style: none;
}
.nav-tabs-fake>li {
float: left;
    margin-bottom: -1px;
}
.nav-fake>li {
position: relative;
    display: block;	
}
.nav-tabs-fake>li.active>a {
color: #555;
    cursor: default;
    background-color: #fff;
    border: 1px solid #ddd;
    border-bottom-color: transparent;	
}
.nav-tabs-fake>li>a {
margin-right: 2px;
    line-height: 1.42857143;
    border: 1px solid transparent;
    border-radius: 4px 4px 0 0;	
}
.nav-fake>li>a {
position: relative;
    display: block;
    padding: 10px 15px;	
}
.nav-tabs-fake:after {
	content:"";
	display:block;
	clear:both;
}
table th,table tr,table td {
text-align: center;
vertical-align:middle;
}


.modal-dialog {
		max-width: 1000px;
	}
	
	.p-c-flexwrapper {
		display:flex;
		align-items:center;
		margin-right:16px;
		margin-bottom:16px;
	}
	
	.p-c-flexwrapper > span {
		width:110px;
	}
	.p-c-flexwrapper > .form-control {
		width:150px;
	}
	#addAndEditModal .modal-body {
		display:flex;
		flex-wrap:wrap;
	}
	.modal-dialog {
		max-width: 1000px;
	}
</style>
</head>
<body class="layui-layout-body">
	<div class="div-c-controlBtns" style="display:flex;justify-content:flex-start;">
		<button class="btn btn-primary" id="button-i-addNewZongDaiLi">新增</button>
	</div>   	
	<div>
		<div class="layui-inline-dd">
			<table
				class="class-tableDataTable class-table-needClick display table table-striped table-bordered table-hover"
				id="table_id_example">
				<thead>
					<tr>
						<th class="class-th" style="display: none;"></th>
						<th class="class-th">彩种名称</th>
						<th class="class-th">返水比率</th>
						<th class="class-th">状态</th>
						<th class="class-th">操作</th>
					</tr>
				</thead>
				<tbody  id="chax">
				</tbody>
			</table>
		</div>
	</div>


		<!-- 新增 -->
	<div class="modal fade" id="addAndEditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		    <div class="modal-dialog">
		        <div class="modal-content">
		            <div class="modal-header">
		            <h5 class="modal-title" id="myModalLabel"> 添加返水率</h5>
		                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><br>
		                <span style="font-size:12px;color:red;"> 注意：比率格式为1以下的小数 格式：0.20</span>
		            </div>
		            <form>
		            <div class="modal-body">
		            	<p class="p-c-flexwrapper"><span>彩种名称：</span>
			            	<select id="input-i-leixing" required class="input-auto form-control" >
			            		<option value="1">五分六合彩</option>
			            		<option value="2">香港六合彩</option>
			            	</select>
		            	</p>
		            	<p class="p-c-flexwrapper p-special2"><span>返水比率：</span><input id="input-i-fanshuilv" type='text' class="form-control" style="width:128px;"/></p>
		            </div>
		            </form>
		            <div class="modal-footer">
		                <button type="button" class="btn btn-primary" id="button-i-submitZongDaiLi">提交</button>
		                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
		            </div>
		            </div>
		            </div>
		            </div>
		            
		            
		            
		            
	  <!-- 修改 -->
<div class="modal fade" id="addNewIpBaiFanShui" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="myModalLabel"> 修改返水率</h5>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <br><span style="font-size:12px;color:red;"> 注意：比率格式为1以下的小数 格式：0.20</span>
            </div>
            <div class="modal-body">
            	<input hidden="hidden" class="fandian-auto" id="input-i-id" value=""/>
            	<input hidden="hidden" class="fandian-auto" id="input-i-type" />
            	<!-- <input style="display: none;" id="input-i-id" /> -->
            	<p style="display:flex;align-items:center;">
	            	<span style="width:100px;display:inline-block;margin-left:30px;">返水比率：</span><input style="width:128px;"  class="fandian-auto form-control" required id="input-i-fdianlv1" />
            	</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn-i-addNewWhiteIp">提交更改</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
	
	<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script>
	var gc_money
	$("#button-i-addNewZongDaiLi").on("click",function(){
		$("#addAndEditModal").modal("show");
	})
	$("#button-i-submitZongDaiLi").on("click",function(){
		$("#addAndEditModal").modal("hide");
		var rebate = $("#input-i-fanshuilv").val();
		if(rebate==''){
			alert("请填写返水比率!");
			return;
		}
		$.ajax({
			type: "POST",
       	 	url: "/czgl/insertSpecialCodeRebate.do",
       	 	data:{
       	 		"gc_rebate":$("#input-i-fanshuilv").val(),
       	 		"gc_money": $('#input-i-leixing').find("option:selected").text()
       	 		},
       	 	success:function(data){
       	 	if(data.data == 1){
  	 			alert("新增成功！")
  	 			findSpecialCodeRebate();
   	 		}else{
   	 			alert("新增失败！")
   	 			findSpecialCodeRebate();
   	 		}
       	 	}
		})
	})
	function findSpecialCodeRebate(){
		$.ajax({
				type: "POST",
	       	 	url: "/czgl/findSpecialCodeRebate.do",
	       	 	data:{
	       	 	},
	       	 	success:function(data){
	       	 		var datas = data.data;
	       	 		var tbody = $("#chax");
   	 				tbody.empty();
	       	 		for(var i = 0; i<data.data.length;i++){
		       	 		var stateValue = ""
		       			 if (datas[i].gc_state == "1") {
		       				 stateValue = "checked"
		       			 } else {
		       				 stateValue = ""
		       			 }
		       	      	 	tbody.append('<tr><td class="id-edit-td hidden-td">'+datas[i].id+'</td><td class="gc_money-td ">'+datas[i].gc_money+'</td><td class="td-rebate">'+datas[i].gc_rebate+'</td>'+"<td><input class='input-c-mySwitch' data-size='small' type='checkbox' " + stateValue + " data-on-text='启用' data-on-color='success' data-off-color='danger' data-off-text='禁用' /></td><td><button style='margin-right:10px' class='btn btn-info btn-editBaiMingDanItem btn-sm' data-name='"+datas[i].gc_money+"'>修改</button><button class='btn btn-danger btn-c-delBankInfo btn-sm butt-shanchu'>删除</button></td></tr>");
		       	      	 $(".input-c-mySwitch").bootstrapSwitch()
	       	 		}
	       	 	}
			});
	}
	findSpecialCodeRebate();
	var id;
	   bindJinYongQiYongSwitch("#table_id_example", "/czgl/updateSpecialCodeRebate.do", "gc_state"); 
		$("#chax").on("click", ".btn-editBaiMingDanItem", function(e) {
			gc_money=$(this).parent().siblings(".gc_money-td").text()
			$("#input-i-fdianlv1").val($(this).parent().siblings(".td-rebate").text())
			 id=$(this).parent().siblings(".id-edit-td").text()
			$("#addNewIpBaiFanShui").modal("show")
		})
	
		$("#btn-i-addNewWhiteIp").on("click", function(e) {
			$("#addNewIpBaiFanShui").modal("hide");
			var rebate = $("#input-i-fanshuilv1").val();
			if(rebate==''){
				alert("请填写返水比率!");
				return;
			}
				$.ajax({
				type: "POST",
	       	 	url: "/czgl/updateSpecialCodeRebate.do",
	       	 	data:{
	       	 		"id":id,
	       	 		"gc_rebate":$("#input-i-fdianlv1").val()
	       	 		},
	       	 	success:function(data){
		       	 	if(data.data == 1){
		   	 			alert("修改成功！")
		   	 			findSpecialCodeRebate();
		   	 		}else{
		   	 			alert("修改失败！")
			 			findSpecialCodeRebate();
		   	 		}
	       	 	}
			})
		})
		
			$("#chax").on("click", ".butt-shanchu", function(e) {
			$.ajax({
				type: "POST",
	       	 	url: "/czgl/deleteSpecialCodeRebate.do",
	       	 	data:{
	       	 		"id":$(this).parent().prev().prev().prev().prev().text(),
	       	 		 "name":$(this).parent().prev().prev().prev().text()
	       	 		},
	       	 	success:function(data){
	       	 	if(data.data == 1){
	   	 			alert("删除成功!")
	   	 			findSpecialCodeRebate();
	   	 		}else{
	   	 			alert("删除失败!")
		 			findSpecialCodeRebate();
	   	 		}
	       	 	}
			})
		})
	</script>
</body>
</html>